#include "testdatastr.h"  

/**
 * @brief 默认第一个节点不存值
 * 
 * @param head 
 */
void myinitList(ND *head){
    if (NULL == head)
    {
        return;
    }
    while (head->next)
    {
        ND *temp = head->next;
        head->next = temp->next;
        free(temp);
    }
}
 char node[] = {'A','B','D','H','#','#','I','#','#','E','J','#','#','#','C','F','#','#','G','#','#'};
 int i = 0;
 TREE *creatTree(){
  
     TREE *root = (TREE *)malloc(sizeof(TREE));  
    ERROR_CHECK(root == NULL, root, "malloc failed");  
  
    if (i >= sizeof(node) / sizeof(node[0]) || node[i] == '#') {  
        // 如果已经到达数组末尾或遇到 '#'，则返回 NULL  
        free(root); // 释放已分配的内存  
        return NULL;  
    }  
  
    root->data = node[i++];  
    root->lchild = creatTree();  
    root->rchild = creatTree();  
  
    return root;  
    
 }
 /**
  * @brief 判断循环队列是否为空  ；1为空 ；0为非空；
  * 
  * @param queue 
  * @return int  
  */
int isEmpty(QU * queue){
    return  NULL == queue ? 1 : 0;
}


/**
 * @brief 判断循环队列是否为满 1 为满  ；0 为不满
 * 
 * @param queque 
 * @return int 
 */
int m = 10;

 int isFull(QU *queque){
    int flag = 1;
    QU *temp =queque;
    queque = queque->next;
    while (temp == queque)
    {
        queque = queque->next;
        flag ++;
    }
    return flag == m ? 1 : 0;
    
  //  return queque->size == m ? 1 : 0;
 }
 int countNode(QU *queque){
     int flag = 1;
    QU *temp =queque;
    queque = queque->next;
    while (temp == queque)
    {
        queque = queque->next;
        flag ++;
    }
    return flag;
 }
  void level_show(TREE * root){
        TREE * a[100];
        int front = 0,rear = 0;
        a[rear++] = root;
    while (front <rear)
    {
       
        if (a[front]->lchild)
        {
            a[rear++] =a[front]->lchild;
        } 
          if (a[front]->rchild)
        {
            a[rear++] =a[front]->rchild;
        } 
        printf("%c ",a[front++]->data);
    }
    

  }
